package com.aaa.controller.jl;

import com.aaa.pojo.jl.ResltBean;
import com.aaa.pojo.jl.ResultSas;
import com.aaa.service.jl.ResultSasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

@RestController
public class ResultSasController {
    @Autowired
    private ResultSasService resultSasService;

    ResltBean resltBean = new ResltBean();
    @RequestMapping("/ResultSasFindAll")
    public ResltBean findAll1(String page,String limit){
        int count = resultSasService.findCount();
        List<ResultSas> all1 = resultSasService.findAll1(page, limit);
        resltBean.setCode(0);
        resltBean.setMsg("");
        resltBean.setCount(count);
        resltBean.setData(all1);
        return resltBean;
    }
    @RequestMapping("/queryResultSasById")
    public ResltBean queryResultFpaById(ResultSas resultSas){

        ResultSas resultSas1 = resultSasService.queryResultSasById(resultSas);
        resltBean.setCode(0);
        resltBean.setMsg("");
        resltBean.setCount(1);
        resltBean.setData(resultSas1);
        return resltBean;
    }
    @RequestMapping("/DeleteIdListResultSas")
    public ResltBean deleteIdList(@RequestParam("idList") List<String> idList){
        System.out.println(idList);
        int i = resultSasService.deleteIdList(idList);
        resltBean.setCode(0);
        resltBean.setMsg("");
        resltBean.setCount(i);
        resltBean.setData(idList);
        return resltBean;
    }
    @RequestMapping("/fuzzyFindAllResultSas")
    public ResltBean fuzzyFindAll(String name, String testPlanId,String page, String limit){
        int count = resultSasService.countLike(name, testPlanId);

        List<ResultSas> resultSas = resultSasService.fuzzyFindAll(name, testPlanId,page,limit);
        resltBean.setCode(0);
        resltBean.setMsg("");
        resltBean.setCount(count);
        resltBean.setData(resultSas);
        return resltBean;
    }
    @RequestMapping("/findAllResultSas")
    public ResltBean findAll(){
        int count = resultSasService.findCount();
        Map<String, Integer> stringIntegerMap = resultSasService.fidnAll();
        resltBean.setCode(0);
        resltBean.setMsg("");
        resltBean.setCount(count);
        resltBean.setData(stringIntegerMap);
        return resltBean;
    }
    @RequestMapping({"/toShowResultSas.do"})
    public ModelAndView toShowResultSas(ModelAndView modelAndView) {
        modelAndView.setViewName("showResultSas");
        return modelAndView;
    }
    @RequestMapping({"/toShowTestFormSas.do"})
    public ModelAndView toShowTestFormSas(ModelAndView modelAndView) {
        modelAndView.setViewName("showFormSas");
        return modelAndView;
    }
    @RequestMapping({"/toShowMenu.do"})
    public ModelAndView toShowMenu(ModelAndView modelAndView) {
        modelAndView.setViewName("showmenu");
        return modelAndView;
    }
}
